package org.objective.dal.commands;

import org.common.service.ServiceRegister;
import org.objective.base.BaseObjectInfo;
import org.objective.command.AuthToken;
import org.objective.command.Command;
import org.objective.command.CommandResult;
import org.objective.command.VoidCommandResult;
import org.objective.service.DalService;
import static org.utils.fp.collection.CollectionFactory.*;

/**
 *
 * @author gus
 */
public class InsertObjectCommand implements Command
{
    private static final long serialVersionUID = -2728354501670285895L;

    private final BaseObjectInfo info;
    public InsertObjectCommand(BaseObjectInfo objectInfo)
    {
        this.info = objectInfo;
    }


    @Override
    public Object[] getParameters()
    {
        return array(info);
    }

    @Override
    public CommandResult execute(ServiceRegister provider, AuthToken token) throws Exception
    {
        DalService service = provider.getService(DalService.class);
        service.insertObject(info);
        return new VoidCommandResult();
    }
}
